package exec;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;

public class CompareTime {

	public static void main(String[] args) {
		try {
			long start = System.nanoTime();
			BufferedReader br = new BufferedReader(new FileReader(
					"E:\\BaiduNetdiskDownload\\www.csdn.net.sql"),
					20 * 1024 * 1024);
			int num = 0;
			while (br.readLine() != null) {
				num++;
			}
			br.close();
			long end = System.nanoTime();
			System.out.println("耗时：" + (end - start) + "毫微秒");
			long start2 = System.nanoTime();
			BufferedInputStream bin = new BufferedInputStream(
					new FileInputStream(
							"E:\\BaiduNetdiskDownload\\www.csdn.net.sql"),
					20 * 1024 * 1024);
			int ch = 0;
			int k = 0;
			while ((ch = bin.read()) != -1) {
				if (ch == '\n')
					k++;
			}
			bin.close();
			long end2 = System.nanoTime();
			System.out.println("耗时：" + (end2 - start2) + "毫微秒");
			System.out.println("第一次" + num + "," + "第二次：" + k + "行");
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}

	}
}
